﻿using Cart.Bll;
using Cart.model;
using MVCProject.API;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace Cart.Api.Controllers
{
    public class SpecController : ApiController
    {
        // GET: api/Spec
        public ResultData<List<SpecDto>> Get()
        {
      var data = new SpecBll().Query(); ;
            ResultData<List<SpecDto>> result = new ResultData<List<SpecDto>>();
            var list = from key in data
                       select new SpecDto
                       {
                           GSKID = key.gskId,
                           Name = key.name,
                           Values = from v in key.GoodsSpecValue
                                    select new SpecValueDto
                                    {
                                        GSVID = v.gsvId,
                                        Value = v.value,
                                        Code = v.code
                                    }
                       };
            result.code = 1;
            result.msg = "ok";
            result.data = list.ToList();

            return result;
        }


        // GET: api/Spec/5
        public string Get(int id)
        {
            return "value";
        }

        // POST: api/Spec
        public void Post([FromBody]string value)
        {
        }

        // PUT: api/Spec/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE: api/Spec/5
        public void Delete(int id)
        {
        }
    }
}
